package com.xy.biz.mes.domain.converter;

import com.xy.biz.mes.domain.po.ManufactureTaskGoodsPO;
import com.xy.biz.mes.domain.bo.ManufactureTaskGoodsBO;
import com.xy.biz.mes.domain.query.ManufactureResultGoodsQuery;
import com.xy.biz.mes.domain.query.ManufactureTaskGoodsQuery;
import com.xy.biz.mes.domain.req.ListManufactureResultGoodsRequest;
import com.xy.biz.mes.domain.req.ListManufactureTaskGoodsRequest;
import com.xy.biz.mes.domain.req.SaveManufactureTaskGoodsRequest;
import com.xy.biz.mes.domain.resp.GetManufactureTaskGoodsResponse;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 *
 *
 * @author zsp
 * @date 2022-1-6
 */
public class ManufactureTaskGoodsConverter {

	public static ManufactureTaskGoodsPO toPO(ManufactureTaskGoodsBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureTaskGoodsPO(), true);
	}

	public static List<ManufactureTaskGoodsPO> toPO(Collection<ManufactureTaskGoodsBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureTaskGoodsPO(), true);
	}

	public static ManufactureTaskGoodsBO fromPO(ManufactureTaskGoodsPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureTaskGoodsBO());
	}

	public static List<ManufactureTaskGoodsBO> fromPO(Collection<ManufactureTaskGoodsPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureTaskGoodsBO());
	}

	public static ManufactureTaskGoodsBO toBO(SaveManufactureTaskGoodsRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ManufactureTaskGoodsBO(), true);
	}

	public static List<ManufactureTaskGoodsBO> toBO(Collection<SaveManufactureTaskGoodsRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ManufactureTaskGoodsBO(), true);
	}

	public static GetManufactureTaskGoodsResponse toResponse(ManufactureTaskGoodsBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetManufactureTaskGoodsResponse());
	}

	public static List<GetManufactureTaskGoodsResponse> toResponse(Collection<ManufactureTaskGoodsBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetManufactureTaskGoodsResponse());
	}

	public static ManufactureTaskGoodsQuery toQuery(ListManufactureTaskGoodsRequest source) {
		if(null == source) {
			return null;
		}
		ManufactureTaskGoodsQuery target = new ManufactureTaskGoodsQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}
}
